import { _decorator, Component, Node, ScrollView, Prefab, Label } from 'cc';
import {GameData} from "./framework/GameData";
// import {ResourceUtilClass} from "./framework/resourceUtilClass";
import {PoolManager} from "./framework/poolManager";
import {Board} from "./Board";
import { bdlMgr } from 'db://assets/Script/Manager/BundleManager_S';
const { ccclass, property } = _decorator;

@ccclass('MatchMap')
export class MatchMap extends Component {
    @property(Node)
    boardNode: Node = null!;

    private matchId:number = 0;
    public setMatchId(id:number){
        this.matchId = id;
        GameData.getInstance().matchId = this.matchId;
        new Board(this.boardNode,()=>{

        })
    }

    onLoad() {

    }

    async onClickMatch(){
        console.log("this.matchId=",this.matchId);
        GameData.getInstance().matchId = this.matchId;

        // 打开对局
        // let prefab = await ResourceUtilClass.loadTheRes("prefab/chessboard", Prefab) as Prefab;
        const prefab = await bdlMgr.getRes<Prefab>(`Xiangqi_Prefab`, `chessboard`, Prefab);
        let node = PoolManager.instance.getNode(prefab,GameData.getInstance().rootNode);

        // 隐藏残局列表
        let matchList = GameData.getInstance().rootNode.getChildByName("matchList");
        matchList.active = false;
    }
}

